home *** CD-ROM | disk | FTP | other *** search
- class smashing.keithm.BaseCamera
- {
- var __dimensions;
- var x;
- var y;
- var z;
- var fl;
- var farClip;
- var __bound_left;
- var __bound_right;
- var __bound_top;
- var __bound_bottom;
- var left;
- var right;
- var top;
- var bottom;
- var __DEF_CLIP = 100000;
- var fl_DEF = 1000;
- var __EDGE_PADDING = 50;
- function BaseCamera(t_data)
- {
- this.__dimensions = t_data.dimensions;
- this.x = this.y = this.z = 0;
- if(t_data.x != undefined)
- {
- this.x = t_data.x;
- }
- if(t_data.y != undefined)
- {
- this.y = t_data.y;
- }
- if(t_data.z != undefined)
- {
- this.z = t_data.z;
- }
- this.fl = this.fl_DEF;
- this.farClip = this.__DEF_CLIP;
- this.refreshEdges();
- }
- function update(dt)
- {
- }
- function setBounds(left, right, top, bottom)
- {
- this.__bound_left = left + this.__dimensions.HALF_WIDTH;
- this.__bound_right = right - this.__dimensions.HALF_WIDTH;
- this.__bound_top = top + this.__dimensions.HALF_HEIGHT;
- this.__bound_bottom = bottom - this.__dimensions.HALF_HEIGHT;
- }
- function enforceBounds()
- {
- if(this.x < this.__bound_left)
- {
- this.x = this.__bound_left;
- }
- else if(this.x > this.__bound_right)
- {
- this.x = this.__bound_right;
- }
- if(this.y < this.__bound_top)
- {
- this.y = this.__bound_top;
- }
- else if(this.y > this.__bound_bottom)
- {
- this.y = this.__bound_bottom;
- }
- }
- function refreshEdges()
- {
- this.left = this.x - this.__dimensions.HALF_WIDTH;
- this.right = this.x + this.__dimensions.HALF_WIDTH;
- this.top = this.y - this.__dimensions.HALF_HEIGHT;
- this.bottom = this.y + this.__dimensions.HALF_HEIGHT;
- }
- function get sc()
- {
- return this.__dimensions.sc;
- }
- function screenWidth()
- {
- return this.__dimensions.SCREEN_WIDTH;
- }
- function screenHeight()
- {
- return this.__dimensions.SCREEN_WIDTH;
- }
- function halfWidth()
- {
- return this.__dimensions.HALF_WIDTH;
- }
- function halfHeight()
- {
- return this.__dimensions.HALF_HEIGHT;
- }
- function toString()
- {
- return "Camera : focus : " + this.x + " , " + this.y + " , " + this.z;
- }
- }
-